﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace _00_委托的练习
{
    public delegate void DelChangeButtonEanble(bool enable);
    public delegate void DelChangeTextBoxText(int runSpeed, int StarSpeed, int StopSpeed);

    public partial class Form1 : Form
    {
        public static DelChangeButtonEanble delChangeButtonEanble = null;
        public static DelChangeTextBoxText delChangeTextBoxText = null;
        public Form1()
        {
            InitializeComponent();
            //实例化委托对象
            delChangeButtonEanble = new DelChangeButtonEanble(ChangeButtonEanble);
            delChangeTextBoxText = new DelChangeTextBoxText(ChangeTextBoxText);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Form2 form2 = new Form2(int.Parse(this.textBox1.Text),int.Parse(this.textBox2.Text),int.Parse(this.textBox3.Text));
            form2.Show();

            ChangeButtonEanble(false);
        }

        public void ChangeButtonEanble(bool enable)
        {
            this.button1.Enabled = enable;
        }

        public void ChangeTextBoxText(int runSpeed, int StarSpeed, int StopSpeed)
        {
            this.textBox1.Text = runSpeed.ToString();
            this.textBox2.Text = StarSpeed.ToString();
            this.textBox3.Text = StopSpeed.ToString();
        }

    }
}
